package com.fymxy.question_bank_management.controller;

        import com.baomidou.mybatisplus.core.metadata.IPage;
        import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
        import com.fymxy.question_bank_management.pojo.ApiResult;
        import com.fymxy.question_bank_management.pojo.Paper;
        import com.fymxy.question_bank_management.service.PaperService;
        import com.fymxy.question_bank_management.service.ProblemService;
        import com.fymxy.question_bank_management.util.ApiResultHandler;
        import org.springframework.beans.factory.annotation.Autowired;
        import org.springframework.web.bind.annotation.GetMapping;
        import org.springframework.web.bind.annotation.PathVariable;
        import org.springframework.web.bind.annotation.RestController;

@RestController
public class PaperManageController {

    @Autowired
    private PaperService paperService;

    @Autowired
    private ProblemService problemService;

    @GetMapping("/showPapers/{page}")
    public ApiResult showAllPaper(@PathVariable("page") Integer page){
        Page<Paper> paperPage = new Page<>(page,10);
        IPage<Paper> paperIPage = paperService.selectAllPaper(paperPage);
        return ApiResultHandler.buildApiResult(200,"查询试卷成功",paperIPage);
    }

    @GetMapping("/showPaperDetail/{paperNo}")
    public ApiResult showPaperDetail(@PathVariable("paperNo") Integer paperNo){
        return ApiResultHandler.buildApiResult(200,"查询试卷题目成功",problemService.selectByPaper(paperNo));
    }
}
